package com.retaileye.rescan;

import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.retaileye.rescanlib.ReScanSDK;

public class MainActivity extends AppCompatActivity implements ReScanSDK.IReScanResult {

    TextView tvBarcode;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        tvBarcode = findViewById(R.id.tvBarcode);
        findViewById(R.id.btnStart).setOnClickListener(v -> {
            ReScanSDK.getInstance().startBarScan(this, this);
        });
        ReScanSDK.getInstance().init(this, this);
    }

    @Override
    public void onCancel() {
        Toast.makeText(this, "取消扫描", Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onPermissionRestricted() {
        Toast.makeText(this, "没有权限", Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onSuccess(String content) {
        tvBarcode.setText(content);
    }
}
